package com.extension.company.common.utils;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.extension.company.admin.R;


public class ToastUtil {
	/**
	 * 吐司
	 *
	 * @param context 上下文
	 * @param msg     信息
	 */
	public static void showToast(Context context, String msg, int duration) {
		if (!TextUtils.isEmpty(msg)) {
			Toast mToast = new Toast(context);
			mToast.setDuration(duration);
			mToast.setGravity(Gravity.CENTER, 0, Utils.Dp2Px(context, 10));
			View view = LayoutInflater.from(context).inflate(R.layout.utils_toast, null);
			mToast.setView(view);
			TextView tv_msg = (TextView) view.findViewById(R.id.tv_msg);
			tv_msg.setText(msg);
			mToast.show();
		}
	}

	/**
	 * 吐司
	 *
	 * @param context 上下文
	 * @param msg     信息
	 */
	public static void showToast(Context context, String msg) {
		if (!TextUtils.isEmpty(msg)) {
			Toast mToast = new Toast(context);
			mToast.setDuration(Toast.LENGTH_LONG);
			mToast.setGravity(Gravity.CENTER, 0, Utils.Dp2Px(context, 10));
			View view = LayoutInflater.from(context).inflate(R.layout.utils_toast, null);
			mToast.setView(view);
			TextView tv_msg = (TextView) view.findViewById(R.id.tv_msg);
			tv_msg.setText(msg);
			mToast.show();
		}
	}
}



